package com.qf.pojo;

import java.util.List;

/**
 * @author 高圆圆
 * @date 2022/12/28 15:58
 * 自定义分页实体
 */
public class PageBean<T> { //泛型代表针对任意实体都可以分页

    private int currentPage ;//当前页码
    private int pageSize ; //每页显示的条数
    private int totalPage ;// 总页数
    private int totalCount ; //总记录数
    private List<T> list ;  //分页列表数据

    public PageBean() {
    }

    //有参构造
    public PageBean(int currentPage,int pageSize, int totalCount, List<T> list) {
        this.currentPage= currentPage ;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.list = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    //总页数
    public int getTotalPage() {

        return (totalCount % pageSize==0)?(totalCount/pageSize):((totalCount/pageSize)+1);
    }

    //总页数不需要赋值,计算出来
   /* public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }*/

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", list=" + list +
                '}';
    }
}
